#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int count = 0,i,j;
	string s("     We  are     going   home    ");
	string ret;
	for ( i = s.size() - 1,j = s.size()-1; i >= 0; i--)
	{
		if (s[i] != ' ')
			count = 0;
		else if (s[i] == ' ' && count == 0)
		{
			string tmp(s.substr(i + 1, j - i ));
			ret += tmp;
			count++;
			j = i;
		}
		else
		{
			j = i;
			count++;
		}
	}
	string tmp(s.substr(0, j));
	ret += tmp;
	cout << ret;
	return 0;
}